/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.client;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

/**
 *
 * @author Wanderley Filho
 */
public class CrudUsuarioPresent {

    Display display;

    interface Display {

        Button getBtCadastrar();

        ListBox getLista();

        void isMorador();

        TextBox getTbCep();
        
        void doGet(String cep);

    }

    CrudUsuarioPresent(Display tela) {
        this.display = tela;
        bind();

    }

    private void bind() {

        display.getBtCadastrar().addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                new DialogBoxCadastro().show();
            }
        });

        display.getLista().addChangeListener(new ChangeListener() {

            @Override
            public void onChange(Widget sender) {
                display.isMorador();
            }
        });

        display.getTbCep().addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
                display.doGet(display.getTbCep().getText());
                
                    
            }
        });
    }

}
